package com.key.center;

import com.key.unusual.Assert;

/**
 * @Author dzl
 * @Date 2021/12/13 9:51 上午
 * keyCenter建造工厂
 */
public class KeyCenterBuildFactory {
    public static KeyCenter KEY_CENTER;
    private static final Integer LENGTH = 16;

    static {
        /*初始化默认中心*/
        KEY_CENTER = new BaseKeyCenter();
    }

    /**
     * 自定义配置中心
     *
     * @param keyCenter /
     */
    public static void createKeyCenter(KeyCenter keyCenter) {
        if (keyCenter == null) {
            Assert.error("初始化KeyCenter不可以为null");
        }
        /*数据效验*/
        if (keyCenter.SecretKey().length() < LENGTH) {
            Assert.error("加密的key值不可以小于16个字节");
        }
        KEY_CENTER = keyCenter;
    }

}
